Skip to content

fix(pool): reject queued requests on end#4291

Open
gilboom wants to merge 1 commit into
sidorares:masterfrom
gilboom:codex/reject-queued-pool-requests-on-end
Open

fix(pool): reject queued requests on end#4291
gilboom wants to merge 1 commit into
sidorares:masterfrom
gilboom:codex/reject-queued-pool-requests-on-end

Conversation

@gilboom
Copy link
Copy Markdown

@gilboom gilboom commented May 7, 2026

What changed

Reject connection requests that are already queued in BasePool._connectionQueue when pool.end() closes the pool.

Why

When a promise pool is saturated and additional pool.query() calls are waiting for a connection, calling pool.end() marks the pool as closed and closes the active connections, but the queued callbacks are never invoked. The promise wrappers for those queued queries can stay pending forever.

This makes queued requests behave consistently with new getConnection() calls after pool closure, which already receive Pool is closed..

Validation

  • Added an integration regression test that saturates a promise pool, waits until two queries are queued, calls pool.end(), and asserts the queued queries reject with Pool is closed. instead of timing out.
  • Verified the new test fails before the fix with timed out waiting for queued queries to settle; queue length=2.
  • CI=1 MYSQL_PASSWORD=root MYSQL_DATABASE=mysql node --import tsx test/integration/test-pool-end.test.mts
  • npm run lint

@codecov
Copy link
Copy Markdown

codecov Bot commented May 7, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 91.00%. Comparing base (f66f87e) to head (4a5e703).

Additional details and impacted files
@@           Coverage Diff           @@
##           master    #4291   +/-   ##
=======================================
  Coverage   91.00%   91.00%           
=======================================
  Files          90       90           
  Lines       14521    14525    +4     
  Branches     1868     1871    +3     
=======================================
+ Hits        13215    13219    +4     
  Misses       1306     1306           
Flag Coverage Δ
compression-0 90.27% <100.00%> (+<0.01%) ⬆️
compression-1 90.98% <100.00%> (+<0.01%) ⬆️
static-parser-0 88.73% <100.00%> (+<0.01%) ⬆️
static-parser-1 89.48% <100.00%> (+<0.01%) ⬆️
tls-0 90.45% <100.00%> (+<0.01%) ⬆️
tls-1 90.78% <100.00%> (+<0.01%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@gilboom gilboom marked this pull request as ready for review May 7, 2026 10:35
@gilboom gilboom marked this pull request as draft May 7, 2026 10:41
@gilboom gilboom marked this pull request as ready for review May 7, 2026 10:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant